<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zhanglh
  Date: 2019/9/10/010
  Time: 19:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>日志管理</title>
    <link href="${pageContext.request.contextPath}/layui/css/layui.css" type="text/css" rel="stylesheet">
    <style>
        /*复选框位置居中*/
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
            top: 50%;
            transform: translateY(-50%);
        }
    </style>
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
    <script type="application/javascript" src="${pageContext.request.contextPath}/layui/layui.js"></script>
</head>
<body>
<%--数据表--%>
<table id="all"></table>

<%--工具栏--%>
<div class="layui-btn-group" id="myToolbar" style="display: none">
    <div class="layui-inline">
        <div class="layui-input-inline">
            <select name="logType" id="logType" lay-verify="required">
                <option value="">请选择操作类型</option>
                <option value="insert">insert</option>
                <option value="delete">delete</option>
                <option value="update">update</option>
                <option value="select">select</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <input type="text" id="logContent" placeholder="在此输入日志内容" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-primary" onclick="search()">
                <i class="layui-icon">&#xe615; 搜索</i>
            </button>
        </div>
    </div>
</div>

<script type="text/javascript">
    // 表格信息
    layui.use(["table", "form", "upload"], function () {
        var table = layui.table;
        var form = layui.form;
        table.render({
            elem: "#all",
            url: "${pageContext.request.contextPath}/log/all",
            page: true,
            toolbar: "#myToolbar",
            cols: [[
                // {type: "checkbox"},
                {title: "序号", type: "numbers"},
                // {title: "编号", field: "userId", width: 60},
                {title: "管理员", field: "adminName"},
                {title: "操作时间", field: "logDate"},
                {title: "操作内容", field: "logContent"},
                {title: "操作类型", field: "logType"},
                {title: "访问IP", field: "logIp"}
                // {title: "操作", templet: "#operating"}
            ]]
        });
    });

    // 搜索
    function search() {
        var logType = $("#logType").val();
        var logContent = $("#logContent").val();
        layui.use('table', function () {
            var table = layui.table;
            table.reload("all", {
                where: {"logType": logType, "logContent": logContent}
            })
        })
    }
</script>
</body>
</html>
